import React from 'react'
import {Input ,Radio ,Select ,Button ,message } from 'antd';
import './index.less';
import axios from 'axios';
import {PATH,IP} from '../../../utils/urls';
import BreadcrumbCustom from "../../../components/BreadcrumbCustom";
const { Option } = Select;
export default class ChangePassWord extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            oldPW:"",
            newPW:""
        };
    }

    componentDidMount() {
    }


    /**
     * 修改个人信息
     * @returns {*}
     */
    onSubmit=()=>{
        console.log(this.state);
        let sendData = {
            newPassword :this.state.newPW,
            oldPassword :this.state.oldPW,
        };
        axios.post(PATH.changePassWord,sendData).then(response=>{
            console.log(response);
            if(response.data.code == 0){
                message.success(response.data.msg);
            }else{
                message.error(response.data.msg);
            }
        })
    }

    /**
     * 输入框值变化
     * @returns {*}
     */
    inputChange = (event)=> {
        console.log(event.target.id);
        if (event && event.target && event.target.value) {
            if (event.target.id == "editEquipMentInput0") {
                this.state.oldPW = event.target.value;
            } else if (event.target.id == "editEquipMentInput1") {
                this.state.newPW = event.target.value;
            }
        }
    }

    render() {
        return (
            <div>
                <BreadcrumbCustom first="系统设置" second="修改密码" />
                <div className="changeAllContent">
                    <div className="resourceContentCell">
                        <div className="changeTitle">旧密码:</div>
                        <Input id={"editEquipMentInput0"} className="changeCell" placeholder="请输入旧密码" onChange={event=>this.inputChange(event)}/>
                    </div>
                    <div className="resourceContentCell">
                        <div className="changeTitle">新密码:</div>
                        <Input id={"editEquipMentInput1"} className="changeCell" placeholder="请输入新密码" onChange={event=>this.inputChange(event)}/>
                    </div>
                    <div className="resourceContentCell">
                        <div className="changeTitle">重新输入:</div>
                        <Input id={"editEquipMentInput2"} className="changeCell" placeholder="请重新输入新密码" onChange={event=>this.inputChange(event)}/>
                    </div>
                    <div className="resourceContentCell changeHardBtnDiv">
                        <Button className="changeHardBtn" onClick={this.onSubmit}>修改</Button>
                    </div>
                </div>
            </div>
        )
    }
}